{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
{*    <link rel="stylesheet" type="text/css" href="/css/mediation/user/index.css" />*}
    <link rel="stylesheet" type="text/css" href="/css/mediation/mediationorgan/addandedit.css" />

{/block}

{block name="page_section"}

<input type="hidden" role-ele="edit">
    <div class="sessionPage">
        <div class="page-header">
          <div class="left">
            <span class="line"></span>
            <strong class="tit">用户编辑</strong>
          </div>
        </div>
        <div class="row mr-none">
            <form class="form-horizontal col-lg-9 pad-no" action="/user/edit" method="POST" role="ajaxfrom" enctype=“multipart/form-data”>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label">姓名</label>
                    <div class="col-sm-7">
                        <input type="text" name="user[name]" value="{if isset($adminUser['name'])}{$adminUser['name']}{/if}" class="form-control" id="inputEmail3" placeholder="请输入~" data-valid="notempty">
                        <span class="error-tips"></span>
                        <input type="hidden" name="user[id]" value="{if isset($adminUser['id'])}{$adminUser['id']}{/if}" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label">手机号</label>
                    <div class="col-sm-7">
                        <input type="tel" name="user[mobile]" value="{if isset($adminUser['mobile'])}{$adminUser['mobile']}{/if}" class="form-control" id="inputEmail3" placeholder="请输入~" data-valid="notempty|mobile">
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                        <label for="exampleInputFile" class="col-sm-4 control-label">调解部门</label>
                        <div class="col-sm-7">
                            <select class="form-control" name="user[mediationOrganId]" id="mediationOrganId">
                                <option role-ele="roleid" value="0" show-status="0" id="role_0">请选择</option>
                                {foreach from=$mediationOrgan key=key item=item}
                                    <option {if !empty($adminUser['mediationOrganId']) &&  $adminUser['mediationOrganId'] == {$item.id}} selected="selected" {/if} value="{$item.id}">{$item.name}</option>
                                {/foreach}
                            </select>
                            <span class="error-tips"></span>
                        </div>



                </div>
                <div class="form-group" id="dataType_div">
                    <label for="inputEmail3" class="col-sm-4 control-label">数据权限</label>
                    <div class="col-sm-7">
                        <select name="user[dataType]" id="dataType" class="form-control">
                            <option role-ele="roleid" value="1" {if $adminUser['dataType'] == 1}selected{/if} >仅自己</option>
                            <option role-ele="roleid" value="2"  {if $adminUser['dataType'] == 2}selected{/if}>本部门</option>
                            <option role-ele="roleid" value="3"  {if $adminUser['dataType'] == 3}selected{/if}>全部</option>
                            <option role-ele="roleid" value="4"  {if $adminUser['dataType'] == 4}selected{/if}>自定义部门</option>
                        </select>
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group" id="mediationOrgan" {if $adminUser['dataType'] !=4 }style="display: none"{/if}>
                    <label for="exampleInputFile" class="col-sm-4 control-label">可查看部门</label>
                    <div class="col-sm-7">
                        <!-- <select class="form-control" name="user[allowOrganId]" id="allowOrganId">
                            <option role-ele="roleid" value="0" show-status="0" id="role_0">请选择</option>
                            {foreach from=$mediationOrgan key=key item=item}
                                <option value="{$item.id}" {if in_array($item.id,$adminUser['allowOrganId'])} selected {/if}>{$item.name}</option>
                            {/foreach}
                        </select> -->
                        <div class="form-control" name="user[allowOrganId]" id="allowOrganId" style="height:auto;">
                          {foreach from=$mediationOrgan key=key item=item}
                            <p style="display:flex;align-items:center;">
                              <input style="margin:5px 10px;" type="checkbox" name="user[allowOrganId][]" value="{$item.id}" {if in_array($item.id,$adminUser['allowOrganId'])} checked {/if}>
                              {$item.name}
                            </p>
                          {/foreach}
                        </div>
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label">用户角色</label>
                    <div class="col-sm-7">
                        <select name="user[role_id]" id="userroleid" class="form-control">
                            {foreach from=$roleArr key=key item=item}
                                <option role-ele="roleid" value="{$item['id']}" {if $adminUser['role_id'] == $item['id']}selected{/if} show-number="{$item['show_number']}" id="role_{$item['id']}">{$item['title']}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label">状态</label>
                    <div class="col-sm-7">
                        <select name="user[status]" id="userstatus" class="form-control">
                            {foreach from=$statusArr key=key item=item}
                                <option role-ele="userstatus" value="{$key}" {if $adminUser['status'] == $key}selected{/if}>{$item}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips"></span>
                    </div>
                </div>

                <div class="form-group" id="workerId1" >
                    <label for="inputEmail3" class="col-sm-4 control-label">线路1坐席(移动线路)</label>
                    <div class="col-sm-7">
                        <select name="user[workerId]" id="userjobnumber" class="form-control">
                            <option role-ele="userjobnumber" value="0" {if $adminUser['workerId'] == 0}selected{/if}>请选择，如无需要可以不选</option>
                            {foreach from=$jobNumArr key=key item=item}
                                <option role-ele="userjobnumber" value="{$item}" {if $adminUser['workerId'] == $item}selected{/if}>{$item}-{$skillGroup[$item]}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group" id="workerId1" >
                    <label for="inputEmail3" class="col-sm-4 control-label">线路2坐席(联通线路)</label>
                    <div class="col-sm-7">
                        <select name="user[workerId2]" id="userjobnumber" class="form-control">
                            <option role-ele="userjobnumber" value="0" {if $adminUser['workerId2'] == 0}selected{/if}>请选择，如无需要可以不选</option>
                            {foreach from=$jobNumArr2 key=key item=item}
                            <option role-ele="userjobnumber" value="{$item}" {if $adminUser['workerId2'] == $item}selected{/if}>{$item}-{$skillGroup[$item]}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label">公示坐席</label>
                    <div class="col-sm-7">
                        <input type="tel" name="user[showWorkerId]" value="{if isset($adminUser['showWorkerId'])}{$adminUser['showWorkerId']}{/if}" class="form-control" id="inputEmail3" placeholder="请输入~">
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label">官网展示照片</label>
                    <div class="col-sm-7">
                        <i class="glyphicon glyphicon-file" style="font-size: 35px;"></i>
                        {if $adminUser['avatarImg']}
                        <span>重新上传照片</span>
                        {else}
                        <span>上传照片</span>
                        {/if}
                        <input type="file" class="uploadFile" name="file" id="upfile" style="opacity: 0;position: absolute;left: 0;top: 0;right: 0;bottom: 0;cursor: pointer;">
                        <span class="error-tips"></span>
                    </div>
                </div>
                {if $adminUser['avatarImg']}
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-4 control-label"></label>
                    <div class="col-sm-7">
                        <img width="70px" height="100px" id='avatarImage' src="{$adminUser['avatarImg']}" style="margin-left: 50px"/>
                        <input type="hidden" id="avatarImg" name="user[avatarImg]" value="{if isset($adminUser['avatarImg'])}{$adminUser['avatarImg']}{/if}">
                        <div style="float:right;text-align:left;cursor:pointer" class="delHead">删除</div>
                    </div>
                </div>
                {/if}
        <input type="hidden" name="id" value="{if isset($adminUser['id'])}{$adminUser['id']}{/if}">
        <div class="form-group mr-t50 mr-b20">
            <button type="submit" id="submit" data-url="/user/add" class="btn btn-primary  col-lg-2 col-md-offset-2">保存</button>
                    <a href="/user/index">
                        <button type="button" class="btn btn-default col-lg-2 col-md-offset-2">返回</button>
                    </a>
                </div>
            </form>
        </div>
    </div>
{/block}
{block name="page_scripts"}
<script type="text/javascript" src="/js/mediation/user/user.min.js" init="mediation/user/user"></script>
<script type="text/javascript">
    $("#dataType").on("change",function(){
        if($(this).val() == 4){
            $("#mediationOrgan").show();
        }else{
            $("#mediationOrgan").hide();
        }

    });
    </script>

{/block}
